<template>
  <div class="home-page-content">
    <h3>个人信息</h3>
    <div class="user-info-main">
      <h3>
        <span
          ><BtnBox boxWidth="120" isIcon type="light-blue" :text="userInfo.accountStatusName"
        /></span>
        <span
          ><BtnBox isIcon text="修改密码" @BtnClick="openSetPassword()"
        /></span>
      </h3>
    </div>
    <Divider />
    <div class="user-info-content">
      <div class="user-avater">
        <img :src="userInfo.avatarUrl" fit="cover" />
      </div>
      <div class="user-content">
        <h4>{{ userInfo.realName }}</h4>
        <div class="user-info">
          <Row>
            <Col span="8">
              <MainFormItem title="手机号">{{ userInfo.mobile }}</MainFormItem>
            </Col>
            <Col span="8">
              <MainFormItem title="注册时间">{{
                userInfo.registerTime
              }}</MainFormItem>
            </Col>
            <Col span="8">
              <MainFormItem title="状态">{{
                userInfo.accountStatusName
              }}</MainFormItem>
            </Col>
          </Row>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { mapState, mapMutations } from "vuex";

import { getMyInfo } from "@/api/common.js";

export default {
  name: "user-info",
  data() {
    return {
      userInfo: {},
    };
  },

  methods: {
    openSetPassword() {
      this.$router.push({
        path: "/retrievePassword",
      });
    },
    async getMyInfoData() {
      let data = await getMyInfo({});
      this.userInfo = data;
    },
  },
  mounted(){
    this.getMyInfoData()
  }
};
</script>

<style lang="less" scoped>
.user-info-main {
  h3 {
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
  }
  :deep(.btn-box-main) {
    width: 120px;
  }
}
.user-info-content {
  width: 100%;
  display: flex;
  padding: 20px 0 20px 20px;
  border-radius: 8px;
  align-items: center;
  background: linear-gradient(
    to bottom,
    rgba(45, 143, 255, 0.1),
    rgba(255, 255, 255, 0)
  );
  .user-avater {
    width: 84px;
    height: 84px;
    border-radius: 84px;
    overflow: hidden;
    margin-right: 40px;
    img {
      width: 100%;
    }
  }
  .user-content {
    width: 100%;
    h4 {
      font-size: 16px;
    }
  }
  .user-info {
    width: 100%;
  }
}
</style>
